package com.unit_10;
import java.util.InputMismatchException;
import java.util.Scanner;
public class Demo02{
    public static void main(String[] args) {
        Scanner input = new Scanner(System.in);
        boolean continueInput = true;
        do{
            try{
                System.out.print("请输入两个整数：");
                int a = input.nextInt();
                int b = input.nextInt();
                System.out.println("a + b = " + (a + b));
                continueInput = false;
            }catch(InputMismatchException e){
                System.out.println("输入数据错误！请重新输入！");
                input.nextLine(); //丢弃当前行
            }
        }while(continueInput);
    }
}
